/* vim: set ts=2 et sw=2 cindent fo=qroca: */

package com.globant.google.mendoza.malbec;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Utility class for base64 decoding.
 */
public final class Decoder {

  /** The class logger.
   */
  private static Log log = LogFactory.getLog(Decoder.class);

  /**
   * The private constructor.
   */
  private Decoder() {
    // nothing to do.
  }

 /** Base64 decodes the xml representation of this encoded cart.
  *
  * @param base64Data The encoded cart to be decoded.
  *
  * @return Returns a string with the encoded xml cart.
  */
 public static String decode(final String base64Data) {
   log.trace("Entering decode.");

   final String result = new String(Base64.decodeBase64(base64Data.getBytes()));
   log.debug("Decode result: " + result);

   log.trace("Leaving decode.");
   return result;
 }
}

